/*  1:   */ package tt.dz.common;
/*  2:   */ 
/*  3:   */ import com.alibaba.fastjson.JSONException;
/*  4:   */ import com.alibaba.fastjson.parser.DefaultJSONParser;
/*  5:   */ import com.alibaba.fastjson.parser.deserializer.DateDeserializer;
/*  6:   */ import java.lang.reflect.Type;
/*  7:   */ import java.text.ParseException;
/*  8:   */ import java.text.SimpleDateFormat;
/*  9:   */ import java.util.Date;
/* 10:   */ 
/* 11:   */ public class MyDateDeserializer
/* 12:   */   extends DateDeserializer
/* 13:   */ {
/* 14:14 */   public static final MyDateDeserializer instance = new MyDateDeserializer();
/* 15:15 */   private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
/* 16:   */   
/* 17:   */   public Date cast(DefaultJSONParser parser, Type clazz, Object fieldName, Object val)
/* 18:   */   {
/* 19:21 */     if (val == null) {
/* 20:22 */       return null;
/* 21:   */     }
/* 22:25 */     if ((val instanceof Date)) {
/* 23:26 */       return (Date)val;
/* 24:   */     }
/* 25:27 */     if ((val instanceof Number)) {
/* 26:28 */       return new Date(((Number)val).longValue());
/* 27:   */     }
/* 28:29 */     if ((val instanceof String))
/* 29:   */     {
/* 30:30 */       String strVal = (String)val;
/* 31:31 */       if (strVal.length() == 0) {
/* 32:32 */         return null;
/* 33:   */       }
/* 34:   */       try
/* 35:   */       {
/* 36:35 */         return this.dateFormat.parse(strVal);
/* 37:   */       }
/* 38:   */       catch (ParseException localParseException)
/* 39:   */       {
/* 40:40 */         long longVal = Long.parseLong(strVal);
/* 41:   */         
/* 42:42 */         return new Date(longVal);
/* 43:   */       }
/* 44:   */     }
/* 45:46 */     throw new JSONException("parse error");
/* 46:   */   }
/* 47:   */   
/* 48:   */   public SimpleDateFormat getDateFormat()
/* 49:   */   {
/* 50:50 */     return this.dateFormat;
/* 51:   */   }
/* 52:   */   
/* 53:   */   public void setDateFormat(SimpleDateFormat dateFormat)
/* 54:   */   {
/* 55:54 */     this.dateFormat = dateFormat;
/* 56:   */   }
/* 57:   */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.common.MyDateDeserializer
 * JD-Core Version:    0.7.0.1
 */